package org.qqcui.designpattern.patterns.prototype;

/**
 * 原型模式客户端类
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2020-10-18 11:18
 **/
public class Client {

	public static void main(String[] args) {
		Sheep sheep = new Sheep("Tom", 1, "白色");
		sheep.friend = new Sheep("Jack", 2, "黑色");
		Sheep sheep2 = sheep.clone();
		Sheep sheep3 = sheep.clone();
		Sheep sheep4 = sheep.clone();
		Sheep sheep5 = sheep.clone();

		// 下面的friend对象都是浅拷贝
		System.out.println("shepp2=" + sheep2 + ",sheep2.friend=" + sheep2.friend.hashCode());
		System.out.println("shepp3=" + sheep3 + ",sheep3.friend=" + sheep3.friend.hashCode());
		System.out.println("shepp4=" + sheep4 + ",sheep4.friend=" + sheep4.friend.hashCode());
		System.out.println("shepp5=" + sheep5 + ",sheep5.friend=" + sheep5.friend.hashCode());
	}
}
